import { API_PREFIX } from '@/constant';
import { http, type DefaultBodyType, type HttpResponseResolver, type PathParams, type RequestHandlerOptions } from 'msw';



export const apiHttp = {
    post: (path: string, resolver: HttpResponseResolver<PathParams, DefaultBodyType, undefined>, options?: RequestHandlerOptions) => http.post(API_PREFIX + path, resolver, options),
    get: (path: string, resolver: HttpResponseResolver<PathParams, DefaultBodyType, undefined>, options?: RequestHandlerOptions) => http.get(API_PREFIX + path, resolver, options),
}
export const mockStructure = {
    ok(data: Record<string, any>, message?: string) {
        return {
            code: 200,
            data,
            message,
        };
    },
    error(msg: string) {
        return {
            code: 500,
            message: msg,
        };
    },
};